<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="author" content="常伟">
        <title>学生信息管理系统</title>
        <link href="/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <style>
            body{
                padding-top: 50px;
            }
            header{
                background-color: #eee;
                height: 6rem;
            }
            header h1{
                font-size: 2.2rem;
            }
            .toolbar{
                padding: 10px 15px;
            }
            th{
                background-color: #eee;
                font-weight: normal;
            }
            #myModal .control-label{
                text-align: left;
            }
            .glyphicon{
                cursor: pointer;
            }
            .table{
                margin-bottom: 0;
            }
        </style>
    </head>
    <body>
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a href="#" class="navbar-brand">学生信息管理系统</a>
                </div>
                <div id="navbar" class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                        <li><a href="#">首页</a></li>
                        <li class="active"><a href="#">学生管理</a></li>
                    </ul>
                </div>
            </div>
        </nav>
        <header>
            <div class="container">
                <h1>学生查询及管理</h1>
            </div>
        </header>
        <div class="container toolbar">
            <button class="btn btn-success" onclick="location.href='/add'">添加学生</button>
            <button class="btn btn-warning" data-toggle="modal" data-target="#myModal">
                <span class="glyphicon glyphicon-search"></span> 搜索
            </button>
        </div>
        <div class="container">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <tr>
                        <th>姓名</th>
                        <th class="text-center">性别</th>
                        <th class="text-center">年龄</th>
                        <th class="text-center">手机号</th>
                        <th>电子邮箱</th>
                        <th class="text-center">修改</th>
                        <th class="text-center">删除</th>
                    </tr>
                    {{each students as s i}}
                    <tr>
                        <td>{{s.name}}</td>
                        <td class="text-center">{{s.isMale ? '男': '女'}}</td>
                        <td class="text-center">{{s.age}}</td>
                        <td class="text-center">{{s.phone}}</td>
                        <td>{{s.email}}</td>
                        <td class="text-center">
                            <span class="glyphicon glyphicon-edit" onclick="location.href='/edit/{{s.id}}'"></span>
                        </td>
                        <td class="text-center">
                            <span class="glyphicon glyphicon-trash" onclick="removeStudent('{{s.id}}', '{{s.name}}')"></span>
                        </td>
                    </tr>
                    {{/each}}
                </table>
            </div>
            <nav>
                <ul class="pager">
                    <li class="{{page <= 1 ? 'disabled' : ''}}">
                        <a href="{{page <= 1 ? '#' : '/' + (page - 1)}}">上一页</a>
                    </li>
                    <li class="{{page >= pageCount ? 'disabled' : ''}}">
                        <a href="{{page >= pageCount ? '#' : '/' + (page + 1)}}">下一页</a>
                    </li>
                </ul>
            </nav>
        </div>
        
        <!-- Modal -->
        <div class="modal fade" id="removeModal" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">确认要删除吗？</h4>
                </div>
                <div class="modal-body"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger">&#x3000;确定&#x3000;</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">&#x3000;取消&#x3000;</button>
                </div>
                </div>
            </div>
        </div>
        
        <script src="/libs/jquery.js"></script>
        <script src="/libs/bootstrap/js/bootstrap.js"></script>
        <script src="/scripts/index.js"></script>
    </body>
</html>